package ga;

import java.util.ArrayList;
import java.util.Random;



public class Mutation {
	
	
	//Todos os filhos serao muatados
	public static void doMutation(ArrayList<Individual> population){
		Random random = new Random();
		
		
		for (Individual individual : population) {
			
			for(int i = 0; i < individual.getGens().length; i ++){
				//para todos os gens, caso a flag da mutacao ligue
				if (random.nextDouble() < GA_Constants.mutationRate)
				{
					//mute o gen
					individual.getGens()[i] = pso.Utility.between(individual.getF().getMinBoudaries(), individual.getF().getMaxBoudaries());
				}
			}
		}
		
	}
	
	//Todos os filhos serao muatados
	public static void doMutationGaussian(ArrayList<Individual> population){
		Random random = new Random();
		
		
		for (Individual individual : population) {
			
			for(int i = 0; i < individual.getGens().length; i ++){
				//para todos os gens, caso a flag da mutacao ligue
				if (random.nextDouble() < GA_Constants.mutationRate)
				{
					//mute o gen
					individual.getGens()[i] = pso.Utility.betweenGaussian(individual.getF().getMinBoudaries(), individual.getF().getMaxBoudaries());
				}
			}
		}
		
	}
	
}
